package main

import "fmt"

func t1() {
	fmt.Println("开始")
	defer func() {
		fmt.Println("a")
		fmt.Println("b")
	}()
	fmt.Println("结束")
}

func t2() int {
	var a = 10
	defer func() {
		fmt.Println("c1")
		a++
		fmt.Println("c2", a)
	}()
	return a
}

func t3() (a int) {
	defer func() {
		fmt.Println("d1")
		a++
		fmt.Println("d2", a)
	}()
	return
}

func main() {
	fmt.Println("-----------------------------------------------")
	t1()
	fmt.Println("-----------------------------------------------")
	fmt.Println(t2())
	fmt.Println("-----------------------------------------------")
	fmt.Println(t3())
}
